home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_08 / 9n08014c < prev    next >
Text File  |  1991-07-08  |  575b  |  22 lines

  1. /* ldexp function */
  2. #include "xmath.h"
  3.  
  4. double (ldexp)(double x, int xexp)
  5.         {       /* compute ldexp(x, xexp) */
  6.         switch (_Dtest(&x))
  7.                 {       /* test for special codes */
  8.         case NAN:
  9.                 errno = EDOM;
  10.                 break;
  11.         case INF:
  12.                 errno = ERANGE;
  13.                 break;
  14.         case 0:
  15.                 break;
  16.         default:        /* finite */
  17.                 if (0 <= _Dscale(&x, xexp))
  18.                         errno = ERANGE;
  19.                 }
  20.         return (x);
  21.         }
  22.